<%@page import="com.zhuoshi.dao.CustomerDao"%>
<%@page import="com.zhuoshi.bean.CustomerBean"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<% request.setCharacterEncoding("UTF-8"); %>
<%-- <jsp:useBean id="bean" class="com.zhuoshi.bean.CustomerBean" scope="request"></jsp:useBean>
<jsp:getProperty property="*" name="bean"/> --%>
<%
String action = request.getParameter("action");
if("add".equals(action)){
	String custname = request.getParameter("custname");
	String abbreviation = request.getParameter("abbreviation");
	String constracts = request.getParameter("constracts");
	String dept = request.getParameter("dept");
	String quarters = request.getParameter("quarters");
	
	CustomerBean bean = new CustomerBean();
	bean.setCustname(custname);
	bean.setAbbreviation(abbreviation);
	bean.setConstracts(constracts);
	bean.setDept(dept);
	bean.setQuarters(quarters);
	CustomerDao dao = new CustomerDao();
	int rows = dao.add(bean);
	if(rows>0){
		out.print("<script language='javascript'>alert('保存成功！继续添加');location.href='customer_add.jsp';</script>");
	}else{
		out.print("<script language='javascript'>alert('保存失败！');</script>");
	}
}
%>


<!-- saved from url=(0041)http://localhost:8080/EMIS/client_add.jsp -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta http-equiv="Cache-Control" content="no-siteapp">
<link rel="Bookmark" href="http://localhost:8080/favicon.ico">
<link rel="Shortcut Icon" href="http://localhost:8080/favicon.ico">
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="template/H-ui.min.css">
<link rel="stylesheet" type="text/css" href="template/H-ui.admin.css">
<link rel="stylesheet" type="text/css" href="template/iconfont.css">
<link rel="stylesheet" type="text/css" href="template/icheck.css">
<link rel="stylesheet" type="text/css" href="template/skin.css" id="skin">
<link rel="stylesheet" type="text/css" href="template/style.css">


<title>添加客户及联系人 </title>

<script type="text/javascript">
	function test()
	{
		var custname = document.getElementById('custname').value;
		if(custname=="")
		{
			//alert("客户名称不能为空！");
			return false;
		}
		
		var abbreviation = document.getElementById('abbreviation').value;
		if(abbreviation=="")
		{
			//alert("客户简称不能为空！");
			return false;
		}
		
		var constracts = document.getElementById('constracts').value;
		if(constracts=="")
		{
			//alert("联系人不能为空！");
			return false;
		}
		
		var dept = document.getElementById('dept').value;
		if(dept=="")
		{
			//alert("所属部门不能为空！");
			return false;
		}
		
		var quarters = document.getElementById('quarters').value;
		if(quarters=="")
		{
			alert("岗位不能为空！");
			return false;
		}
		
		
		return true;
		
	}
</script><link rel="stylesheet" href="template/layer.css" id="layui_layer_skinlayercss">
<link href="template/WdatePicker.css" rel="stylesheet" type="text/css"></head>

<body>
<article class="page-container">
	<form action="?action=add" method="post" class="form form-horizontal" id="form-member-add" onSubmit="return test(this)">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>客户名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" style="width:350px;" value="" placeholder="" id="custname" name="custname"> 
			</div>
		</div>
		 
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>客户简称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" style="width:350px;" value="" placeholder="" id="abbreviation" name="abbreviation">
			</div>

		</div>
		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>联系人：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" style="width:350px;" value="" placeholder="" id="constracts" name="constracts">
			</div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>所属部门：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" style="width:350px;" value="" placeholder="" id="dept" name="dept">
			</div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>岗位：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" style="width:350px;" placeholder="" name="quarters" id="quarters">
			</div>
		</div>
		
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" id="send" type="submit" value="  提交  ">
				<input class="btn btn-danger radius" type="button" id="transmit" value="关闭并返回" />
			</div>
		</div>
	</form>
</article>

<script type="text/javascript" src="template/jquery.min.js"></script> 
<script type="text/javascript" src="template/layer.js"></script>
<script type="text/javascript" src="template/laypage.js"></script> 
<script type="text/javascript" src="template/jquery.icheck.min.js"></script>
<script type="text/javascript" src="template/WdatePicker.js"></script> 
<script type="text/javascript" src="template/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="template/jquery.validate.min.js"></script> 
<script type="text/javascript" src="template/validate-methods.js"></script> 
<script type="text/javascript" src="template/messages_zh.min.js"></script>
<script type="text/javascript" src="template/H-ui.js"></script>
<a href="javascript:void(0)" class="Hui-iconfont toTop" title="返回顶部" alt="返回顶部" style="display:none"></a> 
<script type="text/javascript" src="template/H-ui.admin.js"></script> 




<script type="text/javascript">
$(function(){ 
       //如果是必填的，则加红星标识. 
       $("form :input.required").each(function(){ 
           var $required = $("<strong class='high'> *</strong>"); //创建元素 
           $(this).parent().append($required); //然后将它追加到文档中 
       }); 
       
       $("#send").click(function(){           //当id为send时,单击触发此方法
           $("form :input").parent().find(".formtips").remove();  
            
           //验证客户名称 
           if( $('#custname').val()=="" ){
        	   var errorMsg = '客户名称不能为空.'; 
        	   $('#custname').parent().append('<span class="formtips onError" style="color:red">'+errorMsg+'</span>'); 
           }
           
             //验证客户简称 
           if( $('#abbreviation').val()=="" ){
        	   var errorMsg = '客户简称不能为空.'; 
        	   $('#abbreviation').parent().append('<span class="formtips onError" style="color:red">'+errorMsg+'</span>'); 
           }
           
         	//联系人 
           if( $('#constracts').val()=="" ){ 
               var errorMsg = '联系人不能为空.'; 
               $('#constracts').parent().append('<span class="formtips onError" style="color:red">'+errorMsg+'</span>'); 
           }
         
         	//所属部门 
           if( $('#dept').val()=="" ){ 
               var errorMsg = '所属部门不能为空.'; 
               $('#dept').parent().append('<span class="formtips onError" style="color:red">'+errorMsg+'</span>'); 
           } 
         
         	//岗位 
           if( $('#quarters').val()=="" ){ 
               var errorMsg = '岗位不能为空.'; 
               $('#quarters').parent().append('<span class="formtips onError" style="color:red">'+errorMsg+'</span>'); 
           } 
           
            
      }).keyup(function(){ 
         $(this).triggerHandler("blur"); 
      }).focus(function(){ 
           $(this).triggerHandler("blur"); 
});//end blur 
       
        //文本框失去焦点后 
       $('form :input').blur(function(){ 
            var $parent = $(this).parent(); 
            $parent.find(".formtips").remove(); 
             
            //验证客户名称 
            if( $(this).is('#custname') ){ 
               if( this.value==""  ){ 
                     var errorMsg = '客户名称不能为空.'; 
                     $parent.append('<span class="formtips onError" style="color:red">'+errorMsg+'</span>'); 
               }else{ 
                      
                     $parent.append('<span class="formtips onSuccess" style="color:green"></span>'); 
               } 
            } 
            
            
            if( $(this).is('#abbreviation') ){ 
               if( this.value==""  ){ 
                     var errorMsg = '客户简称不能为空.'; 
                     $parent.append('<span class="formtips onError" style="color:red">'+errorMsg+'</span>'); 
               }else{ 
                      
                     $parent.append('<span class="formtips onSuccess" style="color:green"></span>'); 
               } 
            } 
          	//联系人 
            if( $(this).is('#constracts') ){ 
               if( this.value==""  ){ 
                     var errorMsg = '联系人不能为空.'; 
                     $parent.append('<span class="formtips onError" style="color:red">'+errorMsg+'</span>'); 
               }else{ 
                     
                     $parent.append('<span class="formtips onSuccess" style="color:green"></span>'); 
               } 
            } 
          
          	//所属部门 
            if( $(this).is('#dept') ){ 
               if( this.value==""  ){ 
                     var errorMsg = '所属部门不能为空.'; 
                     $parent.append('<span class="formtips onError" style="color:red">'+errorMsg+'</span>'); 
               }else{ 
                     
                     $parent.append('<span class="formtips onSuccess" style="color:green"></span>'); 
               } 
            } 
          
          	//岗位 
            if( $(this).is('#quarters') ){ 
               if( this.value==""  ){ 
                     var errorMsg = '岗位不能为空.'; 
                     $parent.append('<span class="formtips onError" style="color:red">'+errorMsg+'</span>'); 
               }
               else{ 
                     
                     $parent.append('<span class="formtips onSuccess" style="color:green"></span>'); 
               } 
            } 
       }).keyup(function(){ 
          $(this).triggerHandler("blur"); 
       }).focus(function(){ 
            $(this).triggerHandler("blur"); 
       });//end blur 
 
        
       //提交，最终验证。 
        
 
      
})
</script> 
 <script type="text/javascript">
    $('#transmit').on('click', function(){
        //刷新页面
        parent.window.location.href='customerlist.jsp';
        //获取窗口索引
        var index = parent.layer.getFrameIndex(window.name);
        //关闭弹出层
        parent.layer.close(index);
    });
</script>

</body>
</html>